Re: Question on locking - Mailing list pgsql-novice

From M. Bastin
Subject Re: Question on locking
Date
Msg-id a06110401bdb0f0509826@[192.168.0.116]
Whole thread Raw
In response to Question on locking  (Steve Tucknott <steve@retsol.co.uk>)
List pgsql-novice
>PostGreSQL 7.4.5
>
>If I have the situation where process 1 has selected record1 from
>table a for update and then process 2 tries to do the same, am I
>right in assuming that process 2 will wait until the first process
>completes the transaction (I've looked at Chapter 12 and this is
>intimated).
>How can I detect the lock on process 2? I want to be able to tell
>the user that the row is tentatively locked and to allow them to
>abort the update attempt. I can't see a 'SET LOCK MODE TO NOT WAIT'
>style command, so how do I stop process 2 from waiting?
>Is the suggested route to interrogate the system tables prior to
>selecting for update, to see if a lock has been applied?

That's the best approach we've come up with in the pgSQL4RB
community.  Check out the pgSQL4RB manual on p.92 for the discussion
and appropriate SQL command.
<http://www.aliacta.com/download/>

As I wrote on this list before myself, I would aslo be very happy
with a 'set lock mode not to wait' or a 'SELECT FOR EDIT' as an
alternative to 'SELECT FOR UPDATE' that would return the user name of
the user locking the record in an error event instead of just wait
for the record to be unlocked.

I'm eager to hear about other people's techniques to handle this problem.

Cheers,

Marc

pgsql-novice by date:

Previous
From: Steve Tucknott
Date:
Subject: Question on locking
Next
From: Michael Fuhr
Date:
Subject: Re: Question on locking